import AsyncStorage from '@react-native-community/async-storage';
import { CLASS_ROOM_STORAGE_KEY_SIGN_IN } from '../constant';

let signInTime = 0;

AsyncStorage.getItem(CLASS_ROOM_STORAGE_KEY_SIGN_IN).then((res: any): void => {
  if (res) {
    const time = JSON.parse(res);
    signInTime = time;
  }
});

export const setSignInTime = (time: number): void => {
  signInTime = time;
  AsyncStorage.setItem(CLASS_ROOM_STORAGE_KEY_SIGN_IN, JSON.stringify(time));
};

export const getSignInTime = (): number => {
  return signInTime;
};
